package com.example.testwebsocket.websocketAPI;

import com.example.testwebsocket.config.ServerEndpointConfigurator;
import org.springframework.stereotype.Component;

import java.io.IOException;

import javax.websocket.CloseReason;
import javax.websocket.EndpointConfig;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;


//,configurator = ServerEndpointConfigurator.class
@ServerEndpoint(value = "/tests")// 指定服务端的配置类
public class testWebSocket {

    //与某个客户端的连接会话，需要通过它来给客户端发送数据
    private Session session;
    @OnMessage
    public void onMessage(String message) throws IOException {
    }
    @OnOpen
    public void onOpen(Session session, EndpointConfig endpointConfig) throws IOException {
        System.out.println("链接成功");
    }
    @OnClose
    public void onClose(CloseReason closeReason) {
    }
    @OnError
    public void onError(Throwable throwable) throws IOException {
    }
}

